package reit.ass3;


/**
 * The Class RentalRequest.
 */
class RentalRequest implements StatusableInterface{

	/** The  id. */
	private final Byte mId;

	/** The  type. */
	private final String mType;

	/** The  size. */
	private final byte mSize;

	/** The  duration. */
	private final byte mDuration;

	/** The  status. */
	private Status mStatus;

	/** The  asset. */
	private Asset mAsset;

	/**
	 * Instantiates a new rental request.
	 *
	 * @param id the id
	 * @param type the type
	 * @param size the size
	 * @param duration the duration
	 */
	public RentalRequest(final Byte id, final String type, final byte size, final byte duration) {
		this.mId = id;
		this.mType = type;
		this.mSize = size;
		this.mDuration = duration;
		this.mStatus = Status.INCOMPLETE;
	}

	/**
	 * Gets the room size.
	 *
	 * @return the room size
	 */
	public int getRoomSize(){
		return mSize;
	}

	/**
	 * Gets the id.
	 *
	 * @return the mId
	 */
	public Byte getId() {
		return mId;
	}

	/**
	 * Gets the type.
	 *
	 * @return the mType
	 */
	public synchronized String getType() {
		return mType;
	}

	/**
	 * Gets the duration.
	 *
	 * @return the mDuration
	 */
	public byte getDuration() {
		return mDuration;
	}

	/* (non-Javadoc)
	 * @see ass3.StatusableInterface#setStatusTo(ass3.Status)
	 */
	public synchronized void setStatusTo(final Status status){
		this.mStatus = status;
		this.notifyAll();
	}

	/**
	 * Gets the status.
	 *
	 * @return the status
	 */
	public synchronized Status getStatus(){
		return mStatus;
	}

	/**
	 * Sets the asset.
	 *
	 * @param asset the new asset
	 */
	public synchronized void setAsset(final Asset asset){
		this.mAsset = asset;
	}

	/**
	 * Gets the asset.
	 *
	 * @return the asset
	 */
	public synchronized Asset getAsset(){
		return (mAsset);
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	public String toString(){
		StringBuilder s= new StringBuilder();
		s.append("Rental Request ");
		s.append(mId);
		s.append('\n');
		s.append("Recieved Asset: ");
		s.append(mAsset.getName());
		s.append(" for ");
		s.append(mDuration);
		s.append(" nights ");
		s.append("Status of Request: ");
		s.append(getStatus());
		s.append('\n');

		return s.toString();

	}


}
